package com.bindapp.model;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;

import com.bindapp.R;
import com.bindapp.activity.BJActivity;
import com.bindapp.adapter.YjAdapter;
import com.bindapp.databinding.ActivityYjlistBinding;
import com.bindapp.listener.RecyclerItemClick;
import com.bindapp.widget.RVItemDecoration;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by tom055 on 2018/7/22.
 */

public class YjlistModel extends BaseModel {
    private ActivityYjlistBinding binding;
    private YjAdapter adapter;
    private List<Object> datalist=new ArrayList<Object>();

    public YjlistModel(Context context){
        super(context);
        for(int i=0;i<3;i++){
            datalist.add(""+i);
        }
        adapter=new YjAdapter(datalist, R.layout.item_yj,-1,new ItemClick());
        binding = DataBindingUtil.inflate(LayoutInflater.from(context),R.layout.activity_yjlist,null,false);
binding.recyclerview.setAdapter(adapter);
        binding.recyclerview.addItemDecoration(new RVItemDecoration(30));
        binding.recyclerview.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    }

    class ItemClick implements RecyclerItemClick {

        @Override
        public void onItemClick(int position) {

        }

        @Override
        public void onItemLongClick(int position) {

        }

        @Override
        public void onMoreClick(View view, int position) {
            switch (view.getId()){
                case R.id.btn1:
                    break;
                case R.id.btn2:
                    turnToVc(BJActivity.class,new HashMap<String,String>());
                    break;
            }
            /*Intent intent=new Intent(context, BJActivity.class);
            context.startActivity(intent);*/
        }
    }

    @Override
    public ActivityYjlistBinding getBinding() {
        return binding;
    }
}
